package org.glz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.glz.pojo.Role;
import org.glz.pojo.User;
import org.glz.service.UserService;
import org.glz.vo.Result;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sys/user")
public class UserController {

    @Resource
    private UserService userService;

//    @GetMapping("/user")
//    public ModelAndView index(){
//        return new ModelAndView("sys/user");
//    }

    @GetMapping("/search")
    public Result search(String username, int page, int limit){
        Page<User> pages = userService.search(username,page,limit);
        return Result.success(pages);
    }

    @PostMapping("/add")
    public void addRole(User user){
        System.out.println(user);
        userService.save(user);
    }


}
